{template 'header'}
<link href="{MODULE_URL}template/css/css.css" rel="stylesheet" />
<link href="{MODULE_URL}template/css/stylesheet.css" rel="stylesheet" />
<script src="{MODULE_URL}template/js/galleria.js"></script>
<style type="text/css">
.list {
border-radius: 8px;
}
.list {
background: #fafafa;
padding: 10px;
margin: 5px;
}
.list .hd {
border-bottom: 1px #DDD dotted;
margin-bottom: 5px;
padding-bottom: 5px;
}
.list .content {
color: #545454;
line-height: 25px;
}
.list .reply {
background: #FFF;
border-top: 2px #769cdc solid;
padding: 10px;
margin-top: 10px;
overflow: hidden;
}
.list .content .author {
color: #999;
text-align: right;
margin-top: 10px;
}
#galleria img{
   display: block; position: relative; left: 50px; top: 30px;
   height: 0px;
   width: 0px;
}

</style>
{if $op == 'display'}
<a href="{php echo $this->createMobileUrl('repair',array('op'=>'post'))}" class="top_menu">
    <img src="{MODULE_URL}template/image/fb.png" />报修+
</a>
<div class="top_menu_shadow"></div>
{if empty($list)}
<div class="list img-rounded">没有任何报修记录</div>
{/if}

<div id='list' style='margin-bottom:100px;'>

{loop $list $item}
<div class="list img-rounded" {if $item['img']}style="height:200px;"{/if}>
    <div class="hd">
        <span class="title">{if $item['status'] == 0}<p class="text-danger">未解决</p>{/if}{if $item['status'] == 1}<p class="text-success">已解决</p>{/if}{if $item['status'] == 2}<p class="text-primary">已取消</p>{/if}</span>
        <span class="date">{php echo date('Y-m-d H:i:s', $item['createtime']);}</span>
    </div>
    <div class="content">
        <p><span class="label label-warning">{$item['category']}</span> {$item['content']}</p>
        {if $item['rank']}<p><span class="label label-warning" >满意度：{if $item['rank'] == 1}满意{elseif $item['rank'] == 2}一般{elseif $item['rank'] == 3}差劲{/if}{if $item['comment']}&nbsp;&nbsp;评价内容：{$item['comment']}{/if}</span></p>{/if}
        {if $item['img']}
        <p style='margin-top:5px;'>
            {loop $item['img'] $value}
                <img src="{$value['src']}" style="width: 60px; height: 60px;border:1px solid white;float:left;" />
            {/loop}
        </p>
        {/if}
        
    </div>
   
</div>
<div style='clear: both;'></div>
{/loop}
 
</div>
<div id="galleria"></div>
<div style="display:none;left: 0px;top: 0px;width: 100%;height: 100%;overflow: hidden;position: fixed;background: rgba(0, 0, 0, 0.5);" id="layer">
</div>
{if count($list)>9} 
<div style="margin-top:20px;margin-bottom:70px;text-align:center;font-size:16px;" id='view' >查看更多</div>
{/if}


<script>
    // Load theme
    Galleria.loadTheme('{MODULE_URL}template/lightbox/galleria.lightbox.js');

    $('#galleria').galleria({
        data_source: '#list',
        extend: function() {
            this.bind(Galleria.LOADFINISH, function(e) {
                $(e.imageTarget).click(this.proxy(function(e) {
                    e.preventDefault();
                    this.next();
                }))
            })
        },
        keep_source: true,
        data_config: function(img) {
            return {
                description: $(img).next('.caption').html()
            }
        }
    });
</script>
<script>
var page = 2;
$(function() {
    $(".reply-more-btn").click(function() {
        var a = $(this).parent(".reply");
        a.find(".reply-more").toggle();
        $(this).hide();
    });
    $("#view").click(function() {
        $('#layer').show();
        obj=$(this);
        $(this).html('正在加载中...')
        $.get("{php echo $this->createMobileUrl('repair',array('op'=>'more'))}&page="+page, function(result){
                    if(result!=''){
                        $('#list').append(result);
                        page++;    
                        obj.html('查看更多');
                    }else{
                        obj.html('没有更多信息了');
                    }
                    $('#layer').hide();
            });
        });
});
</script>
{/if}
{if $op == 'post'}
<!--仿微社区上传图片-->
        <link rel="stylesheet" href="{MODULE_URL}template/imgupload/css/comm.css">
        <script type="text/javascript" src="{MODULE_URL}template/imgupload/js/global.js">
        </script>
        <script type="text/javascript" src="{MODULE_URL}template/imgupload/js/gps.js">
        </script>
        <script type="text/javascript" src="{MODULE_URL}template/imgupload/js/seajs-0.1.5.js">
        </script>
        <script type="text/javascript" src="{MODULE_URL}template/imgupload/js/newthread.js">
        </script>
        <script type="text/javascript" charset="utf-8" src="{MODULE_URL}template/imgupload/js/jpegmeta.js">
        </script>
        <script type="text/javascript" charset="utf-8" src="{MODULE_URL}template/imgupload/js/jpeg.encoder.basic.js">
        </script>
        <script type="text/javascript" charset="utf-8" src="{MODULE_URL}template/imgupload/js/image_compress.js">
        </script>
        
<!--仿微社区上传图片-->
<!--仿微社区上传图片-->
        <script type="text/javascript">
            var myurl="{php echo $this->createMobileUrl('imgupload')}";
        </script>
<!--仿微社区上传图片-->
    <form role="form" method="post" enctype="multipart/form-data" onsubmit="return checkInfo(this);" name="newthread" id="newthread" class="form-horizontal">
        <div class="panel panel-default">
          <div class="panel-heading">我要报修</div>
          <div class="panel-body">
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">报修类型</label>
                    <div class="col-sm-10">
                      <select name="category" class='form-control' >
                        {loop $categories $key $category}
                            <option value="{$category['name']}"{if $category['name']==$item['category']} selected{/if}>{$category['name']}</option>       
                        {/loop}
                    </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="content" class="col-sm-2 control-label">报修内容</label>
                    <div class="col-sm-10">
                         <textarea name="content" id='content' class='form-control' rows="4">{$item['content']}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">报修图片(最多可上传3张图片)</label>
                    <div class="col-sm-10">
                        <div class="tipLayer">
                            <div class="photoList">
                                <ul>
                                    <li class="on" id="addPic">
                                        <input type="file" class="on needsclick" style="z-index:200;opacity:0;filter:alpha(opacity=0);-ms-filter:'alpha(opacity=0)';" id="uploadFile" accept="image/*" single>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label"></label>
                    <div class="col-sm-10">
                        <button type="submit" name="submit" value="yes" class="btn btn-primary" style="width:100%;">提交</button>
                        <input type="hidden" name="id" value="{$item['id']}" />
                        <input type="hidden" name="token" value="{$_W['token']}" />
                    </div>
                </div>
          </div>
        </div>
    </form>

{/if}
{if $op == 'resolve'}
<form class="form-horizontal img-rounded" role="form" method="post" >
<div class="panel panel-default">
  <div class="panel-body">
    <div class="form-group">
        <label class="col-sm-2 control-label">类型</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" value='{$item['category']}' disabled="disabled">
           
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">内容</label>
        <div class="col-sm-10">
            <textarea class="form-control" disabled="disabled">{$item['content']}</textarea>
            
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">要求</label>
        <div class="col-sm-10">
            <textarea class="form-control" disabled="disabled">{$item['requirement']}</textarea>
            
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">提交时间</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" value='{php echo date('Y-m-d H:i:s', $item['createtime']);}' disabled="disabled">
           
        </div>
    </div>
    <div class="form-group">
        <label for="rank" class="col-sm-2 control-label">评价</label>
        <div class="col-sm-10">
            <select name="rank" class="form-control">
                <option value="1">满意</option>
                <option value="2">一般</option>
                <option value="3">差劲</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="comment" class="col-sm-2 control-label">内容</label>
        <div class="col-sm-10">
            <textarea name="comment" class="form-control" rows="3"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label for="" class="col-sm-2 control-label"></label>
        <div class="col-sm-10">
            <button type="submit" name="submit" value="yes" class="btn btn-primary" style="width:100%;">提交</button>
            <input type="hidden" name="token" value="{$_W['token']}" />
        </div>
    </div>
  </div>
</div> 
</form>
{/if}

<script type="text/javascript">
function checkInfo(form) {
        if (!form['content'].value) {
            alert('请输入您的报修内容。');
            return false;
        }
        return true;
    }

</script>
{template 'footer'}